﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Transactions;

namespace _1Dot9MasterTransactions
{
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
    public class TransactionAttribute : Attribute
    {
        // Fields
        private IsolationLevel _IsolationLevel;
        private int _Timeout;
        private TransactionOption _TransactionOption;

        // Methods
        public TransactionAttribute()
            : this(TransactionOption.None)
        {
        }

        public TransactionAttribute(TransactionOption option)
        {
            this._TransactionOption = option;
            this._IsolationLevel = IsolationLevel.ReadCommitted;
            this._Timeout = 60;
        }

        // Properties
        public IsolationLevel IsolationLevel
        {
            get
            {
                return this._IsolationLevel;
            }
            set
            {
                this._IsolationLevel = value;
            }
        }

        public int Timeout
        {
            get
            {
                return this._Timeout;
            }
            set
            {
                this._Timeout = value;
            }
        }

        public TransactionOption TransactionOption
        {
            get
            {
                return this._TransactionOption;
            }
            set
            {
                this._TransactionOption = value;
            }
        }
    }
}
